package be.phl.layoutAdapter;

import java.util.List;

import be.phl.obstacleapp.R;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

public class PatientRowAdapter extends ArrayAdapter<PatientRow> {

	private final Context context;
	private final List<PatientRow> patients;

	public PatientRowAdapter(Context context, List<PatientRow> patients) {
		super(context, R.layout.patient_row, patients);
		// TODO Auto-generated constructor stub

		this.context = context;
		this.patients = patients;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {

		LayoutInflater inflater = (LayoutInflater) context
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		View rowView = inflater.inflate(R.layout.patient_row, parent, false);

		TextView firstname = (TextView) rowView.findViewById(R.id.firstname);
		TextView address = (TextView) rowView.findViewById(R.id.address);

		PatientRow patient = patients.get(position);

		firstname.setText(patient.getFirstName());
		address.setText(patient.getAddress());

		return rowView;
	}

}
